package com.example.huaxindemo2.service.impl;

import com.example.huaxindemo2.entity.Pr103en;
import com.example.huaxindemo2.entity.T001;
import com.example.huaxindemo2.mapper.T001Mapper;
import com.example.huaxindemo2.mapper.T002Mapper;
import com.example.huaxindemo2.service.Pr10301Service;
import com.example.huaxindemo2.service.Pr10302Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;

import java.math.BigDecimal;
import java.util.Iterator;
import java.util.List;

@Service
public class Pr10302ServiceImpl implements Pr10302Service {
    @Autowired
    private T001Mapper t001Mapper;

    @Override
    public void pr10302(Model model,String year,String month) {
        List<T001> list = t001Mapper.SelectDateAll(year+"-"+month);
        if(list==null || list.size()==0){
            model.addAttribute("M103001E","M103001E：当月没有订单信息");
        }else{
            List<Pr103en> list2 = t001Mapper.SelectCustomerAmount(year+"-"+month);
            model.addAttribute("list",list2);

            Iterator<Pr103en> iterator = list2.iterator();
            int sum=0;
            while (iterator.hasNext()) {
                sum += iterator.next().getAmount();
            }

            model.addAttribute("sum",sum);
        }

    }
}
